home *** CD-ROM | disk | FTP | other *** search
- Path: anvil.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++
- Subject: Re: C/C++ knocks the crap out of Ada
- Date: 1 Mar 1996 11:11:33 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4h7i55INNknq@anvil.ugrad.cs.ubc.ca>
- References: <JSA.96Feb16135027@organon.com> <4gvrffINNlqo@anvil.ugrad.cs.ubc.ca> <4h4j31$1ga3@watnews1.watson.ibm.com> <dewar.825640041@schonberg>
- NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
-
- In article <dewar.825640041@schonberg>, Robert Dewar <dewar@cs.nyu.edu> wrote:
- >(b) C is actually not in such good shape here, although the ANSI standard
- >has been out for quite a while, the compliance with this standard is stlil
- >by no means universal. For example, just a few months ago, I wrote soe
- >code using the standard which used the returned value from sprintf. It
- >worked fine on OS/2, but bombed on SunOS, whose C compiler library does
- >something non-standard. OK, this sort of thing happens, but it was the
-
- SunOS is an old operating system. SunSoft has since released Solaris, which has
- an ANSI development environment. They probably have available for SunOS
- programming tools which are also more modern---I have no idea.
-
- It is a matter of historical development that C became popular well before its
- standardization, but that does not mean that the standard itself is in bad
- shape.
-
- >response of our local "C expert" that I found interesting, I was told
- >"everyone knows that you should not use the returned value of sprintf
- >if you are writing portable code". Of course the situation gets better
-
- That's obviously false. Not everyone knows it, and poeple get tripped up.
-
- >here with time, and finally the ANSI C standard is starting to have some
- >force.
-
- Yes, some old environments have a sprintf() function that does not have an
- ANSI-compliant return value. The standard provides you a way to detect
- non-compliant systems:
-
- The predefined pre-processor identifier __STDC__ is 1 in standard-conforming
- implementations. You can write a program so that it almost certainly fails to
- translate if this is not present.
-
- Of course, this may not be satsifactory, since you want the program to work!
- And of course, the presence of the symbol does not guarantee that the compiler
- is conforming, due to the lack of an ``official'' validation suite.
-
- >(c) C is much less hostile to extensions than Ada (to validate Ada you have
- >to sign a declaration that you have not implemented any extensions). What
- >this means in practice is that you have to be more careful in C not to
- >wander off into these extensions
-
- Again, this is the advantage of having an official validation suite. Big point
- in Ada's favor, obviously.
-
- >There are many fronts to argue this general point on, but I am afraid you
- >have, through not knowing Ada well, wandered into an area where Ada has
- >very definitely got the upper hand (C++ is of course another matter entirely :-)
-
- True. As I said before, I should not have mistakenly lumped Ada and C++ in the
- same category. It is extremely unfair!
-
- Standardization notwithstanding, any language will allow you to write errnoeous
- programs, whose outcome could have dire consequences. I can write in Ada a
- function that computes something other than what I intend it to compute, as I
- can in C.
-
- Whether I'm more or less likely to do it in C is more of a matter for religious
- debate. Competent software engineers can work with either one and produce
- correct, well-defined results according to the standards. In addition to that,
- all software has to be subject to rigorous quality control, especially
- safety-critical software. That means all kinds of component testing and code
- inspection!
-
- However, consider: If your software complies with the standard for whatever
- language you are using, and can be shown to be free of error and due to some
- faut in the compiler the software fails, causing some damage or injury, you can
- still be considered liable if chose to use a compiler that wasn't validated,
- can you not? If it was certified, you can pass the blame to the implementors of
- the tools. This is where the advantage of an official certification mechanism
- is clear, from the point of view of the user of the programming tools.
- --
-
-